package com.aisile.shop.controller;

import com.aisile.entity.Result;
import com.aisile.pojo.TbSeller;
import com.aisile.sellergoods.service.SellerService;
import com.alibaba.dubbo.config.annotation.Reference;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("seller")
public class SellerController {
    @Reference
    SellerService sellerService;

    @RequestMapping("save")
    public Result save(@RequestBody TbSeller tbSeller){
        try {
            BCryptPasswordEncoder encoder = new BCryptPasswordEncoder();
            String encoder1 = encoder.encode(tbSeller.getPassword());
            tbSeller.setPassword(encoder1);
            sellerService.save(tbSeller);
            return new Result(true,"成功");
        }catch (Exception e){
            return new Result(false,"服务器出现异常");
        }
    }









}
